using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using YayiMgr.Ability.Docking.Commom;
using YayiMgr.Ability.Docking.SuppliersApp;
using YayiMgr.Ability.Docking.SuppliersApp.Dto;

namespace YayiMgr.Web.Controllers
{
    [ApiController]
    [Route("api/[controller]/[action]")]
    public class SuppliersController : ControllerBase
    {
        public ISuppliersServicer SuppliersSvr { get; set; }

        [HttpGet]
        public async Task<QueryListDto<SuppliersDto>> Get()
        {
            return await SuppliersSvr.GetAllSuppliers();
        }

        [HttpPost]
        public async Task<QueryListDto<SuppliersDto>> Get(SuppliersQueryDto input)
        {
            return await SuppliersSvr.GetSuppliers(input);
        }

   
        [HttpGet("{id}")]
        public async Task<ResponseDto<SuppliersDto>> Get(Guid id)
        {
            return await SuppliersSvr.GetSupplierById(id);
        }


        [HttpPost]
        public async Task<ResponseDto<SuppliersDto>> Post(SuppliersCreateDto input)
        {
            return await SuppliersSvr.AddSuppliers(input);
        }


        [HttpPut("{id}")]
        public async Task<ResponseDto<SuppliersDto>> Put(Guid id, SuppliersUpdateDto input)
        {
            return await SuppliersSvr.UpdateSuppliers(id,input);
        }


        [HttpDelete("{id}")]
        public async Task<ResponseDto<Object>> Delete(Guid id)
        {
            return await SuppliersSvr.DeleteSuppliers(id);
        }
    }
}